package com.tsu.mall.common.mapper;

import com.tsu.mall.common.VO.LayuiTableVO;
import com.tsu.mall.common.entity.Member;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author tttttt
 * @since 2023-03-22
 */
public interface MemberMapper extends BaseMapper<Member> {

    List<Member> doSelectListPage(@Param("memberNumber") String memberNumber, @Param("memberPhone") String memberPhone);


    @Update("update member set status=#{newStatus} where id=#{id}")
    void updateByStatus1(@Param("newStatus") String newStatus,@Param("id") Integer id);


    @Update("update member set password=#{password} where id=#{id}")
    void updatePassword(@Param("id") Integer id,@Param("password") String password);

    @Select("select * from member where account_number=#{accountNumber} or phone=#{accountNumber} ;")
    List<Member> check(String accountNumber);

    @Select("select account_number from member where id<>#{id} and account_number=#{accountNumber}")
    String selectAccountNumber(String accountNumber,Integer id);

    @Update("update member set avatar=#{avatar} where id=#{id}")
    void updateMemberAvatar(String avatar, Integer id);

    @Select("select avatar from member where id=#{id}")
    String selectCurrentAvatar(Integer id);

    @Update("update member set password=#{newPassword} where id=#{id}")
    void updatePasswordByMemberId(Integer id, String newPassword);

    @Select("select password from member where id=#{id}")
    String selectPasswordById(Integer id);

    @Select("select * from member where phone=#{phone}")
    Member selectPhoneById(String phone);

    @Insert("insert into member(username,phone,password) values(#{username},#{phone},#{password}) ")
    void reg(String username, String phone, String password);
}
